//
//  BaseViewController.m
//  AppFrameWork
//
//  Created by Le Anh Tai on 7/21/13.
//  Copyright (c) 2013 Le Anh Tai. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NOTIFICATION_CHANGE_THEME object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NOTIFICATION_CHANGE_LANGUAGE object:nil];
    
    [self active];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self loadTheme:[DataSingleton shared].isDarkTheme];
    [self reloadLanguage];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadTheme:(BOOL)isDarkTheme
{
    
}

- (void)reloadLanguage
{
    
}

- (void)active
{
}

- (void)deactive
{
}

- (void)handleNotification:(NSNotification *)sender
{
    NSString *name = sender.name;
    if ([name isEqualToString:NOTIFICATION_CHANGE_THEME])
    {
        [self loadTheme:[DataSingleton shared].isDarkTheme];
    }
    else if ([name isEqualToString:NOTIFICATION_CHANGE_LANGUAGE])
    {
        [self reloadLanguage];
    }
}
@end
